import com.wcarmon.life.model.*;
import com.wcarmon.life.event.*;
import com.wcarmon.life.vo.*;
import mx.controls.Alert;
import mx.events.*;
import mx.utils.*;
import mx.collections.*;
	
include "../../../includes/loggerSnippet.as";
     	

      	
[Bindable]
private var model : LifeModelLocator = LifeModelLocator.getInstance();

      
private function doInit() : void {
	BlockContent.setFocus();
}      	

private function isValid() : Boolean {	
	if( BlockContent.isValid() ){ return false; }
	if( BlockDeadline.isValid() ){ return false; }
	if( BlockRefMeta.isValid() ){ return false; }
	if( BlockProjectIds.isValid() ){ return false; }
	if( BlockUrls.isValid() ){ return false; }
	if( BlockRefCode.isValid() ){ return false; }	
	if( BlockCost.isValid() ){ return false; }
	//if( BlockRefLanguage.isValid() ){ return false; }	//Givon: fix
	//if( BlockRefLanguage.isValid() ){ return false; }	//Givon: fix
	return true;
}

private function saveToInbox() : void {
	if( !isValid() ){
		return;
	}

	var b:BlockVO = new BlockVO();
	b.content = BlockContent.getValue();
	b.deadline = BlockDeadline.getValue();
	b.ref_meta = BlockRefMeta.getValue();
	b.state_id = BlockVO.STATE_COLLECT;
	b.projectIds = BlockProjectIds.getValue();
	b.cost = BlockCost.getValue();
	b.ref_code = BlockRefCode.getValue();
	
	var tmp : Array = BlockUrls.getValue();
	b.url1 = tmp[0];
	b.url2 = tmp[1];

	//b.ref_language = BlockRefLanguage.getValue();
	//b.isPrivate = 0;	//Givon: Fix
	//b.fileIds = ?		//Givon - Fix

	Alert.show('finish this function (file uploads) 785641234');
	log.debug('Collect is about to save...\n' + ObjectUtil.toString(b) );
	///////////////////////////////////////////////
	//( new CreateBlockEvent( b, this ) ).dispatch(); 
}

	
public function doCallback() : void{
	clearForm();
} 

private function clearForm() : void{
	BlockRefCode.clearValue();
	BlockUrls.clearValue();
	BlockDeadline.clearValue();
	BlockContent.clearValue();
	BlockRefMeta.clearValue();	
	BlockCost.clearValue(); 
	BlockProjectIds.clearValue();
	//BlockRefLanguage.clearValue();	//Givon: fix ...make the field

	BlockContent.setFocus();      		
} 
      	